package missPuff.com;

import java.util.List;

import model.com.VideoInfo;
import utils.com.FilesUtils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import database.com.DatabaseHelper;

public class LocalVideoActivity extends Activity{

	private ListView localVideolist;
	private DatabaseHelper databaseHelper;
	private List<VideoInfo> videoInfos = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.localvideo);	
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		
		localVideolist = (ListView) findViewById(R.id.list_localvideo);
		FilesUtils filesUtils = new FilesUtils(LocalVideoActivity.this);
		videoInfos = filesUtils.getVideoFiles("MissPuff");		
		localVideolist.setAdapter(new LocalVideoAdapter(this, videoInfos));
		super.onResume();
		
		
		localVideolist.setOnItemClickListener(new OnItemClickListener()
	    {

			public void onItemClick(AdapterView<?> arg0, View v, int position, long id) 
			{
				// TODO Auto-generated method stub
				Intent listIntent = new Intent();
				VideoInfo videoData = videoInfos.get(position);
				listIntent.putExtra("videoData", videoData);
				listIntent.setClass(LocalVideoActivity.this, VideoLocalPlayActivity.class);
				LocalVideoActivity.this.startActivity(listIntent);
			}
		});
	}

}
